<template>
  <div class="technology-create">
    <el-page-header class="page-head" @back="$router.back()" title="所有技术">
      <template #content>
        <span style="font-weight: 600;">创建技术</span>
      </template>
    </el-page-header>
    <el-form
    label-position="right"
    label-width="120px"
    style="max-width: 800px">
      <el-form-item label="技术名字">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="技术说明">
        <el-input v-model="form.detail" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit" :disabled="!formSubmitEnable">创建技术</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { post } from '../../../utils/common/api'

export default {
  data() {
    return {
      form: {
        name: '',
        detail: ''
      },

      formSubmitEnable: true
    }
  },

  methods: {
    onSubmit() {
      var that = this
      console.log(this.form)
      post('/technology/create', this.form).then(function(res) {
        ElNotification({
          title: '技术创建成功',
          message: `您刚刚创建了 ${res.name} 技术条目。`,
          type: 'success',
          position: 'bottom-right',
        })
        that.$router.back()
      })
    }
  }
}
</script>

<style scoped>
.page-head {
  margin-bottom: 40px;
}
</style>